package school.entity;

import java.io.Serializable;
import java.util.*;

public class Page<T> implements Serializable {
	private int pageNo;// 当前页号
	public static final int PAGESIZE = 20;// 页大小

	private int totalPages;// 总页数
	private int totalLines;// 总条数
	private List<T> datas = new ArrayList<T>();

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getTotalLines() {
		return totalLines;
	}

	/**
	 * 设置总条数的同时，计算总页数
	 * 
	 * @param totalLines
	 */
	public void setTotalLines(int totalLines) {
		this.totalLines = totalLines;
		this.totalPages = (totalLines / PAGESIZE)
				+ (totalLines % PAGESIZE == 0 ? 0 : 1);
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public List<T> getDatas() {
		return datas;
	}

	public void setDatas(List<T> datas) {
		this.datas = datas;
	}
}
